#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<string.h>
#include<assert.h>
#include<netinet/in.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<arpa/inet.h>

int initClient(char *str){
    

    int tcp_socket_fd = socket(AF_INET,SOCK_STREAM,0);

    struct sockaddr_in server_addr = {0};
    server_addr.sin_family = AF_INET;
    server_addr.sin_port = htons(9999);
    server_addr.sin_addr.s_addr = inet_addr("127.0.0.1");

    int ret = connect(tcp_socket_fd,(struct sockaddr *)&server_addr,sizeof(server_addr));
    while(ret != 0){
        sleep(1);
        ret = connect(tcp_socket_fd,(struct sockaddr *)&server_addr,sizeof(server_addr));
    }
    printf("connect successful!\n");

    write(tcp_socket_fd,str,strlen(str));
    printf("%s",str);

    close(tcp_socket_fd);


    return 1;
    
}